//
//  NSArray+Additions.h
//  OCStarterProject
//
//  Created by huaya on 2025/10/2.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSArray<ObjectType> (Additions)

/// 安全的数组，如果为空返回空数组
- (NSArray *)safeArray;

/// 判断数组是否为空
- (BOOL)isNotEmpty;

/// 安全的获取数组元素，防止越界
- (id)safeObjectAtIndex:(NSUInteger)index;

/// 将数组转换为JSON字符串
- (NSString *)toJSONString;

/// 数组去重
- (NSArray *)removeDuplicates;

/// 根据指定key对数组进行分组
- (NSDictionary *)groupByKey:(NSString *)key;

- (nullable ObjectType)wx_objectOrNilAtIndex:(NSUInteger)index;

@end

NS_ASSUME_NONNULL_END
